package kr.co.bettersoft.carrotmemberstore.adapter;

import java.util.List;

import kr.co.bettersoft.carrotmemberstore.R;
import kr.co.bettersoft.carrotmemberstore.domain.PostAddress;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
/*
 * 
 */
public class PostAddressListAdapter extends BaseAdapter {
	String TAG  = "PostAddressListAdapter";
	private Context context;
	private final List<PostAddress> entries;
// 
	public PostAddressListAdapter(Context context, List<PostAddress> entriesFn) {		
		this.context = context;
		this.entries = entriesFn;
		Log.d(TAG,"entries - "+entries.size());
	}
 
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View listView;
		if (convertView == null) {
			listView = new View(context);
			listView = inflater.inflate(R.layout.register_page2_wrapper, null);
		} else {
			listView = (View) convertView;
		}
 
//		String  tmpStr = ((PostAddress)entries.get(position)).getZipcode()+((PostAddress)entries.get(position)).getSido()+" "+((PostAddress)entries.get(position)).getGugun()+" "+((PostAddress)entries.get(position)).getDong()+" "+((PostAddress)entries.get(position)).getBunji();
//		Log.d(TAG,position+" / tmpStr:"+tmpStr);

		// set value into textview
//		TextView register2_right_zipcode = (TextView) listView.findViewById(R.id.register2_right_zipcode);
//		register2_right_zipcode.setText(tmpStr);
		
		
		TextView textView1 = (TextView) listView.findViewById(R.id.register2_right_zipcode);
		
		textView1.setText(((PostAddress)entries.get(position)).getZipcode());
//		Log.d(TAG,position+" / register2_right_dong:"+((PostAddress)entries.get(position)).getDong());
		TextView textView2 = (TextView) listView.findViewById(R.id.register2_right_sido);
		textView2.setText(((PostAddress)entries.get(position)).getSido());
		TextView textView3 = (TextView) listView.findViewById(R.id.register2_right_gugun);
		textView3.setText(((PostAddress)entries.get(position)).getGugun());
		TextView textView4 = (TextView) listView.findViewById(R.id.register2_right_dong);
		textView4.setText(((PostAddress)entries.get(position)).getDong());
		TextView textView5 = (TextView) listView.findViewById(R.id.register2_right_bunji);
		textView5.setText(((PostAddress)entries.get(position)).getBunji());
//
//		TextView textView3 = (TextView) listView.findViewById(R.id.customer_update_date);
//		textView3.setText(context.getString(R.string.recent_update)+" : "+((CheckMileageMileage)entries.get(position)).getLastUpdateDate());
//		TextView textView4 = (TextView) listView.findViewById(R.id.customer_register_date);
//		textView4.setText(context.getString(R.string.register_date)+"         : "+((CheckMileageMileage)entries.get(position)).getRegisterDate());

		return listView;
	}
 
	@Override
	public int getCount() {
		return entries.size();
	}
 
	@Override
	public Object getItem(int position) {
		return null;
	}
 
	@Override
	public long getItemId(int position) {
		return 0;
	}
 
}